//
//  PopViewButton.swift
//  weibobbaj
//
//  Created by Tiffany宝 on 16/4/30.
//  Copyright © 2016年 Tiffany. All rights reserved.
//

import UIKit

class PopViewButton: UIButton {
    
    //当前的表情按钮对应的表情模型
    var emotion: EmotionModel?{
        
        didSet{
            
            //因为 //清空表情 ~~ popView.popViewButton.emotion = nil
            guard let _ = emotion else{
                return
            }
            
            if emotion?.type == "1"{
                self.titleLabel?.font = UIFont.systemFontOfSize(33)
                //emoji 表情
                self.setTitle((emotion!.code! as NSString).emoji(), forState: UIControlState.Normal)
                self.setImage(nil, forState: UIControlState.Normal)
            }else{
                
                let image = UIImage(named: "\(emotion!.folderName ?? "")/\(emotion!.png ?? "")", inBundle: EmotionKeyboardViewModel.sharViewModel.loadBundle(), compatibleWithTraitCollection: nil)
                self.setImage(image, forState: UIControlState.Normal)
                self.setTitle(nil, forState: UIControlState.Normal)
            }

    }
    }
}
